﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mogre;

namespace WastedMechanics.CharState
{
    public class CharStateRunPistolRecoil : CharStateRun
    {
        public CharStateRunPistolRecoil(Character chr)
            : base(chr, "RunPistolShoot")
        {            
        }

        public override void Enter()
        {            
            base.Enter();
            Character.ResetAnimation(AnimationName);
            Character.IsAiming = true;
        }

        public override void Exit()
        {
            Character.IsAiming = false;
            base.Exit();
        }

        public override void Update()
        {
            base.Update();
            if (Character.AnimBlender.Target.TimePosition > Character.AnimBlender.Target.Length * 0.99f)                            
                if (Character.IsAiming)
                    Character.SwitchState(new CharStateRunPistolAim(Character));
                else
                    Character.SwitchState(new CharStateRunPistol(Character));

        }

        public override void StopAimingOrder()
        {
            Character.IsAiming = false;
        }

        public override void HaltOrder()
        {            
        }        

        public override CharState GetIdleState()
        {
            if (Character.IsAiming)
                return new CharStateIdlePistolAim(Character);
            else
                return new CharStateIdlePistol(Character);
        }

        public override CharState GetFallingState()
        {
            return new CharStateFallPistol(Character);
        }
    }
}
